<?php
/**
 *  本类不负责给键加前缀 Memcache 支持
 *  配置要求
 *  $GLOBALS['Dn_MemServers']=array('host'=>$host,'port'=>'port');
 *  $GLOBALS['Dn_MemServers']=array(0=>array('host'=>$host,'port'=>'port'));
 */
class DnCacheMemory extends DnCache//implements ITwCache
{
	public $cache_data=array();
	public $is_connect = false;
	public $prefix = '';
	public function connect() {
		$this->cache = new Memcached();
		$flag = false;
		$servers=$this->config['servers'];
		foreach ($servers as $config) {
			$flag = $flag || $this->cache->addServer($config['host'], $config['port']);
		}
		
		$this->is_connect = $flag;
		return $falg;
	}
	///////////////////////////////////////////////////////////////////////////
	public function _get($key) {
		//TODO 报错
		return isset($this->cache_data[$key])?$this->cache_data[$key]:false;
		
	}
	public function _set($key, $value, $expire = 0) {
		$this->cache_data[$key]=$value;
		return true;
		
	}
	public function _delete($key) {
		unset($this->cache_data[$key]);
		return true;
	}
}